Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWG-9288 utilizing safe url resolver for OAS 2.0 #2031

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

MiloszTarka
Copy link
Member

@MiloszTarka MiloszTarka commented Jan 4, 2024

Addresses: #2030

This PR makes swagger-parser to utilizes safeUrlResolver when resolving OpenAPI 2.0 definitions.

The reason behind this change is described deeply under the following PR:
#1910

The $refs are checked in ResolverCache class, in loadRef method.

In order to keep the backward compatibility, I've created a new constructor of ResolverCache so it is possible to explicitly pass the parseOptions through the SwaggerResolver.

@MiloszTarka
Copy link
Member Author

I'll add tests soon & similar PR to v3 parser

Copy link
Member

@frantuma frantuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, just 2 possible changes in constructors

@@ -66,6 +66,27 @@ public ResolverCache(Swagger swagger, List<AuthorizationValue> auths, String par
this.swagger = swagger;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of duplicating logic in constructor I would suggest to call this(swagger, auths, parentFileLocation, new ParseOptions())

@@ -49,6 +50,16 @@ public SwaggerResolver(Swagger swagger, List<AuthorizationValue> auths, String p
parametersProcessor = new ParameterProcessor(cache, swagger);
}

public SwaggerResolver(Swagger swagger, List<AuthorizationValue> auths, String parentFileLocation, Settings settings, ParseOptions parseOptions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of duplicating logic in constructor I would suggest to call in constructor above this(swagger, auths, parentFileLocation, settings, new ParseOptions())

@frantuma frantuma removed the request for review from gracekarina January 8, 2024 18:10
@MiloszTarka
Copy link
Member Author

MiloszTarka commented Jan 10, 2024

Great work, just 2 possible changes in constructors

Great shout, commited changes! Sorry for taking so long to apply the feedback, had to urgently finish other stuff last days.

@MiloszTarka MiloszTarka requested a review from frantuma January 10, 2024 12:34
@MiloszTarka MiloszTarka merged commit 5804358 into v1 Jan 11, 2024
3 checks passed
@MiloszTarka MiloszTarka deleted the SWG-9288-utilizing-safe-url-resolver-for-oas-20 branch January 11, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants